import {
  getFormatterPrice,
  computeRate
} from '@const/filter'

export const purchaseOrderProductListColumns = [
  { width: 45, type: 'selection' },
  { minWidth: '150', prop: 'code', label: '产品编码', 'show-overflow-tooltip': true },
  { minWidth: '130', prop: 'prodName', label: '产品名称', 'show-overflow-tooltip': true },
  { minWidth: '110', prop: 'spec', label: '规格', 'show-overflow-tooltip': true },
  { minWidth: '110', prop: 'model', label: '型号', 'show-overflow-tooltip': true }, // 1
  { minWidth: '100', prop: 'unit', label: '最小单位' }, // 1
  { width: '110',
    prop: 'buyPrice',
    label: '单价(元)',
    'show-overflow-tooltip': true,
    formatter: row => {
      return row.buyPrice ? getFormatterPrice(row.buyPrice)
        : 0
    } },
  { minWidth: '170', prop: 'registNo', label: '注册证号/备案证号' },
  { minWidth: '150', prop: 'manufacturer', label: '生产厂家', 'show-overflow-tooltip': true },
  { width: '100',
    prop: 'bigType',
    label: '产品大类',
    formatter: row => PRODUCT_CATEGORY[row.bigType] },

  { width: '160', prop: 'purchaseNum', label: '采购数量' },
  { width: '120', prop: 'orderAmount', label: '小计金额（元）', formatter: row => getFormatterPrice(computeRate(row.count, row.buyPrice) || 0) }, // 1
  { minWidth: '180', prop: 'dealerName', label: '配送商', 'show-overflow-tooltip': true },
  { width: '150', prop: 'dealerProdCode', label: '配送商产品编码', 'show-overflow-tooltip': true }, // 1
  { width: '60', prop: 'action', label: '操作', fixed: 'right' }
]

// 注册地
export const PRODUCT_REGISTER_TYPE = {
  0: '国产',
  1: '港澳台',
  2: '进口'
}

// 产品大类
export const PRODUCT_CATEGORY = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '低值'
}
